Clip Basics
Previous  Top  Next



You will find information about the following topics:

·Wrapping a Clip around selected text  
·Adding prompts in a Clip  
·Using the Clipbook to launch other programs  
·Program commands  
·Clipbook Programming  


For details on using the Clip editor, see the topic Create Clipbook Libraries. To help you with the Clipbook syntax, a "Clip Assistant" is available under the Tools | Quick List Properties menu. When you activate this command, a list of ready-to-use syntax elements is displayed in place of the Quick List. You can paste the items into your document by double-clicking on them or by dragging them. You can edit the ClipHelp.CLH file if you want to customize the content of the Clip Assistant list.

For those of you who plan to develope many libraries, make sure you take a look at ClipWriter. This program, written by an expert Clip programmer, is a powerful alternative to the NoteTab Clipbook editor. A free trial version is available for evaluation. By visiting the NoteTab Web site, you will also find other useful resources that can help you get to grips with developing Clipbook libraries.


Wrapping a Clip around selected text

Normally, if you select text in your document and then paste an item from the Clipbook, the document selection is replaced by the Clip text. However, if the Clip text item includes the two-character code ^&, the highlighted text in the document is inserted at the code's position and the resulting text is pasted in the document. This feature is particularly useful when producing HTML documents. For example, if you have defined a Clipbook item under the title Italic:

<I>^&</I>  

Selecting text in your document (for example NoteTab) and then double-clicking on the Italic item in the Clipbook will surround the text with the italic tags:

<I>fabulous</I>  


Adding prompts in a Clip

Sometimes you may want to complete a Clip just before it is pasted in your document. HTML tags are a good example where this could come in handy. If you use the sample HTML library that comes with this program, you will notice that when you double-click on the Font item, the program will display a dialog box prompting you to enter a value for the font size. You have a choice to type a value or pick it from a combo box.

Adding this type of behavior to a Clip is very easy. Simply place the two-character code and brackets ^?[] in your Clip at the position where user input should be inserted. For example, when you double-click on a Clipbook item with the following text:

<FONT SIZE=^?[]>  

a dialog box with a plain input field will prompt you to complete the Clip. The user input replaces the two-character code, and then the completed tag is copied to the document. If you would like the prompt to be a bit more descriptive, you can specify the text that will be displayed in the dialog box by placing it between square brackets:

<FONT SIZE=^?[Font size]>  

You can define a default value that will be displayed to the user. Just add an equal sign after the prompt followed by the default text. The following example will show the value 12 in the input field of the dialog box:

<FONT SIZE=^?[Font size=12]>  

You can produce more sophisticated prompts by offering the user a list of choices. When the program detects this type of prompt, it displays a dialog box with a combo box. To specify a list of choices, use an equal sign "=" after the prompt text followed by the values. Use a "|" (Alt+0124) as a separator between the values. For example, the following item will show a combo box labeled "Font size" with the values 8, 10, 12, 14, 18, 24, and 36 in the list:

<FONT SIZE=^?[Font size=8|10|12|14|18|24|36]>  

The user can also enter values that are not listed. If, however, the input should be limited to the values available in the list, just double the equal sign as in the following example:

<FONT SIZE=^?[Font size==10|14|18]>  

If you would like to select a default value when the dialog box is displayed, just place an underscore character "_" in front of the desired value. In the following example, the value 10 will be used as the default value:

<FONT SIZE=^?[Font size=8|_10|14|18]>  

You can display in the combo box list different text from what you actually want to use. Use the ^= code to separate the text to display (on the left side) from the text to use (on the right side). The example below will show a combo box with three items in the list: Small, Medium, Large. The medium item will be selected as the default value since it starts with an underscore character.

<FONT SIZE=^?[Font size=Small^=6|_Medium^=10|Large^=14]>  

A Clip can have as many prompts in it as you like. If you repeat a prompt within the same Clip, the initial answer entered by the user is inserted in its place (the dialog box is not displayed again). In the following example, the user will only be prompted once:

Dear ^?[First Name=Lisa|Bill|Jane|Ted],  
How are you ^?[First Name]?  

Notice that it is not necessary to duplicate the whole prompt item, but only the prompt header. Suppose the user chose Jane, this is what will be pasted in the document:

Dear Jane,  
How are you Jane?  


Using the Clipbook to launch other programs

Any Clipbook item that starts with the two-character code ^!, will be launched when invoked. For example, double-clicking on a Clip with the following text:

^!calc.exe  

will execute the calculator provided with Windows. Note that if the application is not in the search path, you will have to add the fully qualified path to the application you want to use.

Use the DOS command to launch some DOS applications if the method described above does not work:

^!DOS edit.exe  

A Clip can behave a bit like a batch file in that it supports multiple commands - each on a separate line. For example, if you have a Clip with the following instructions:

^!calc.exe  
^!write.exe "c:\My Documents\MyFile.Doc"  

Executing it will open both the calculator and the word processor. You can control the timing for opening consecutive applications. The instruction ^!WAIT will wait until the previously launched application has closed before executing the next command. You cannot use the editor when it is in Wait mode (the editor's window caption indicates it is waiting for the application to close). The instruction ^!PROMPT will display a dialog box prompting the user to click on the OK button before passing on to the next instruction(s). In the following example, the Write program will only be launched once the Calculator program has been closed:

^!calc.exe  
^!WAIT  
^!write.exe "c:\My Documents\MyFile.Doc"  

Note that the ^!WAIT command may not work with all applications (during testing, it did not work with the MS-Write program).

You can specify what message should be displayed in the prompt window. The following example will display a message box with the text "Click on OK when you are ready!":

^!PROMPT Click on OK when you are ready!  

Use the CONTINUE command to give the user the possibility to cancel the execution of all Clip commands following it. The syntax is similar to PROMPT but the message box shows an OK and a Cancel button. If the user presses cancel, the Clip execution is interrupted. The following example will display a message box with the text "Click on OK to continue or Cancel to stop!":

^!CONTINUE Click on OK to continue or Cancel to stop!  

If you want to open the current document in another application, use the three-character code ^** to indicate where the document name should be inserted in the command line. For example, if you want to open the current document in MS-Write, you would use the following command:

^!write.exe ^**  

To specify a document name without its extension, use the following two-character code instead: ^*

Documents that have not been saved are stored in a temporary file when this type of command is used. The temporary file is then substituted for the document name. If you do not want NoteTab to create a temporary file in this case, then substitute the asterisk character "*" with a "#". For example:

^!write.exe ^##  

You can also specify additional parameters that your application recognizes. Here is an example that will do a syntax check on a Perl script (assuming it is the current document in the editor):

^!perl -c ^**  

If you are editing a document that is associated with another application, you do not need to specify the application name. For example, if you are using an HTML document (with the appropriate extension!), the following command will open the current document in the browser that has been associated with HTML extensions:

^!^**  

Note that the ^!WAIT instruction only works with launch commands that include the program name. It will not work with the example above!

You can also open URLs in the associated browser. To do so, the two-character code ^! must be followed by the following text "URL" (without the quotes). For example, the following command will open the link to the NoteTab Homepage:

^!URL http://www.notetab.com/  

You will find more examples in the Clipbook library "Utilities.clb" which is installed with NoteTab.


Program commands

You can execute any NoteTab command that is available in the toolbar (it does not matter if the button is displayed in the toolbar or not). You specify the command you want to execute by using the keyword "TOOLBAR" followed by a space and its tooltip text. The button tooltip text can be seen by placing the mouse cursor over the button or by looking at the content of the list box in the Toolbar properties dialog box.

The following example will activate the "Open Document" command:

^!TOOLBAR Open Document  

You can of course create a sequence of instructions. The next example will create a new document, paste the content of the Clipboard into it, then activate the Save As dialog box:

^!TOOLBAR New Document  
^!TOOLBAR Paste  
^!TOOLBAR Save As  


Clipbook Programming

You can significantly extend the functionality of NoteTab by using more sophisticated features of the Clip language. Starting with NoteTab v4.5, you can create quite sophisticated scripts to handle anything from underlining a title to creating complex Web pages. See the topic Clip Programming for more information on the subject.